package com.ruoyi.energy.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.energy.domain.NyEnteriseLoad;
import com.ruoyi.energy.domain.NyTransPartArrs;
import com.ruoyi.energy.service.INyTransPartArrsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 变压器部件属性Controller
 *
 * @author cjie
 * @date 2021-10-11
 */
@Api(tags = " 变压器部件属性")
@RestController
@RequestMapping("/nyTransPartArrs")
public class NyTransPartArrsController extends BaseController {
    @Autowired
    private INyTransPartArrsService nyTransPartArrsService;

    /**
     * 查询变压器部件属性列表
     */
    @ApiOperation(value="查询变压器部件属性列表", notes="查询变压器部件属性列表")
    @PreAuthorize(hasPermi = "energy:nyTransPartArrs:list")
    @GetMapping("/list")
    public TableDataInfo list(NyTransPartArrs nyTransPartArrs) {
        startPage();
        List<NyTransPartArrs> list = nyTransPartArrsService.selectNyTransPartArrsList(nyTransPartArrs);
        return getDataTable(list);
    }

    /**
     * 导出变压器部件属性列表
     */
    @ApiOperation(value="导出变压器部件属性列表", notes="导出变压器部件属性列表")
    @PreAuthorize(hasPermi = "energy:nyTransPartArrs:export")
    @Log(title = "变压器部件属性", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NyTransPartArrs nyTransPartArrs) throws IOException {
        List<NyTransPartArrs> list = nyTransPartArrsService.selectNyTransPartArrsList(nyTransPartArrs);
        ExcelUtil<NyTransPartArrs> util = new ExcelUtil<NyTransPartArrs>(NyTransPartArrs.class);
        util.exportExcel(response, list, "变压器部件属性数据");
    }
    /**
     * 获取变压器部件属性详细信息
     */
    @ApiOperation(value="获取变压器部件属性详细信息", notes="获取变压器部件属性详细信息")
    @PreAuthorize(hasPermi = "energy:nyTransPartArrs:query")
    @GetMapping(value = "/{attrId}")
    public AjaxResult getInfo(@PathVariable("attrId") Long attrId) {
        return AjaxResult.success(nyTransPartArrsService.selectNyTransPartArrsById(attrId));
    }

    /**
     * 新增变压器部件属性
     */
    @ApiOperation(value="新增变压器部件属性", notes="新增变压器部件属性")
    @PreAuthorize(hasPermi = "energy:nyTransPartArrs:add")
    @Log(title = "变压器部件属性", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NyTransPartArrs nyTransPartArrs) {
        return toAjax(nyTransPartArrsService.insertNyTransPartArrs(nyTransPartArrs));
    }

    @GetMapping("/nyEnteriseLoad/list")
    public TableDataInfo getlist(NyEnteriseLoad nyEnteriseLoad) {
        startPage();
        List<NyEnteriseLoad> list = nyTransPartArrsService.selectNyEnteriseLoadList(nyEnteriseLoad);
        return getDataTable(list);
    }

    /**
     * 修改变压器部件属性
     */
    @ApiOperation(value="修改变压器部件属性", notes="修改变压器部件属性")
    @PreAuthorize(hasPermi = "energy:nyTransPartArrs:edit")
    @Log(title = "变压器部件属性", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NyTransPartArrs nyTransPartArrs) {
        return toAjax(nyTransPartArrsService.updateNyTransPartArrs(nyTransPartArrs));
    }

    /**
     * 删除变压器部件属性
     */
    @ApiOperation(value="删除变压器部件属性", notes="删除变压器部件属性")
    @ApiImplicitParam(name = "ids", value = "变压器部件属性ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "energy:nyTransPartArrs:remove")
    @Log(title = "变压器部件属性", businessType = BusinessType.DELETE)
    @DeleteMapping("/{attrIds}")
    public AjaxResult remove(@PathVariable Long[] attrIds) {
        return toAjax(nyTransPartArrsService.deleteNyTransPartArrsByIds(attrIds));
    }
}
